package com.chao.yyks.modular.hearing.controller;

import com.alibaba.fastjson.JSONObject;
import com.chao.common.util.log.Inter;
import com.chao.common.util.reaction.PageList;
import com.chao.yyks.modular.hearing.bean.EnHearing;
import com.chao.yyks.modular.hearing.service.EnHearingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 听力Controller
 * chao
 * 2024-09-12
 */
@RestController
@RequestMapping("/enHearing")
public class EnHearingController {

	/**
	 * 听力Service
	 */
	@Autowired
	private EnHearingService enHearingService;

	/**
	 * 新增听力
	 */
	@Inter("EHG_ADD_01")
	@RequestMapping(method = RequestMethod.POST, value = "insertEnHearing")
	public void insertEnHearing(@RequestBody EnHearing enHearing){
		enHearingService.insertEnHearing(enHearing);
	}

	/**
	 * 修改听力
	 */
	@Inter("EHG_EDT_01")
	@RequestMapping(method = RequestMethod.POST, value = "updateEnHearing")
	public void updateEnHearing(@RequestBody EnHearing enHearing){
		enHearingService.updateEnHearing(enHearing);
	}

	/**
	 * 重新生成语音文件
	 */
	@Inter("EHG_EDT_02")
	@RequestMapping(method = RequestMethod.POST, value = "updateEnHearingUrl")
	public void updateEnHearingUrl(@RequestBody EnHearing enHearing){
		enHearingService.updateEnHearingUrl(enHearing.getHearingId());
	}

	/**
	 * 重新生成语音文件
	 */
	@Inter("EHG_EDT_03")
	@RequestMapping(method = RequestMethod.POST, value = "updateEnHearingThUrl")
	public void updateEnHearingThUrl(@RequestBody EnHearing enHearing){
		enHearingService.updateEnHearingThUrl(enHearing);
	}


	/**
	 * 物理删除听力
	 */
	@Inter("EHG_DEL_02")
	@RequestMapping(method = RequestMethod.POST, value = "deleteDataEnHearing")
	public void deleteDataEnHearing(@RequestBody EnHearing enHearing){
		enHearingService.deleteDataEnHearing(enHearing.getHearingId());
	}

	/**
	 * 查询听力详情
	 */
	@Inter("EHG_SEL_01")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnHearingByHearingId")
	public EnHearing selectEnHearingByHearingId(String hearingId){
		return enHearingService.selectEnHearingByHearingId(hearingId);
	}

	/**
	 * 查询听力列表
	 */
	@Inter("EHG_SEL_02")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnHearingByList")
	public PageList<EnHearing> selectEnHearingByList(@RequestParam Map<String,Object> map){
		return enHearingService.selectEnHearingByList(new JSONObject(map));
	}

	/**
	 * 分页查询听力列表
	 */
	@Inter("EHG_SEL_03")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnHearingByPage")
	public PageList<EnHearing> selectEnHearingByPage(@RequestParam Map<String,Object> map){
		return enHearingService.selectEnHearingByPage(new JSONObject(map));
	}

	/**
	 * 听力题试卷
	 */
	@Inter("EPH_SEL_04")
	@RequestMapping(method = RequestMethod.POST, value = "selectEnHearing")
	public List<JSONObject> selectEnHearing(@RequestBody JSONObject json){
		return enHearingService.selectEnHearing(json);
	}

	/**
	 * 口语题试卷
	 */
	@Inter("EPH_SEL_05")
	@RequestMapping(method = RequestMethod.POST, value = "selectEnHearingKy")
	public List<EnHearing> selectEnHearingKy(@RequestBody JSONObject json){
		return enHearingService.selectEnHearingKy(json);
	}

}